2015-08-22DB.txt 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. --数码表
  2. if not exists
  3. (select * from syscolumns where id=object_id('tb_ErpOrderDigital') and name='Ordv_SendPhotoName')
  4. begin
  5. alter table tb_ErpOrderDigital add Ordv_SendPhotoName nvarchar(20) NULL
  6. end
  7. IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'tb_ErpOrderDigital', N'COLUMN',N'Ordv_SendPhotoName'))
  8. EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'发片人(按最后一个发片人)' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpOrderDigital', @level2type=N'COLUMN',@level2name=N'Ordv_SendPhotoName'
  9. GO
  10. if not exists
  11. (select * from syscolumns where id=object_id('tb_ErpOrderDigital') and name='Ordv_SendPhotoTime')
  12. begin
  13. alter table tb_ErpOrderDigital add Ordv_SendPhotoTime datetime
  14. end
  15. IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'tb_ErpOrderDigital', N'COLUMN',N'Ordv_SendPhotoTime'))
  16. EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'发片时间(按最后一个发片时间)' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpOrderDigital', @level2type=N'COLUMN',@level2name=N'Ordv_SendPhotoTime'
  17. GO
  18. if not exists
  19. (select * from syscolumns where id=object_id('tb_ErpOrderDigital') and name='Ordv_SendPhotoDispatcher')
  20. begin
  21. alter table tb_ErpOrderDigital add Ordv_SendPhotoDispatcher nvarchar(20) NULL
  22. end
  23. IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'tb_ErpOrderDigital', N'COLUMN',N'Ordv_SendPhotoDispatcher'))
  24. EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'发片安排者' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpOrderDigital', @level2type=N'COLUMN',@level2name=N'Ordv_SendPhotoDispatcher'
  25. GO
  26. if not exists
  27. (select * from syscolumns where id=object_id('tb_ErpOrderDigital') and name='Ordv_SendPhotoDispatchTime')
  28. begin
  29. alter table tb_ErpOrderDigital add Ordv_SendPhotoDispatchTime nvarchar(20) NULL
  30. end
  31. IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'tb_ErpOrderDigital', N'COLUMN',N'Ordv_SendPhotoDispatchTime'))
  32. EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'发片安排时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpOrderDigital', @level2type=N'COLUMN',@level2name=N'Ordv_SendPhotoDispatchTime'
  33. GO
  34. -------- 我的工作_发片师
  35. IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_MyWorkSendPhoto_No')
  36. BEGIN
  37. DROP VIEW [dbo].BView_MyWorkSendPhoto_No
  38. END
  39. GO
  40. SET ANSI_NULLS ON
  41. GO
  42. SET QUOTED_IDENTIFIER ON
  43. GO
  44. IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_MyWorkSendPhoto_No]'))
  45. EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[BView_MyWorkSendPhoto_No]
  46. AS
  47. SELECT
  48. tb_ErpOrder.ID, CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
  49. dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
  50. Cus_Name AS 客户姓名,
  51. dbo.tb_ErpUser.User_DividedShop AS 分店编号, dbo.tb_ErpUser.User_Name AS 员工姓名,
  52. dbo.tb_ErpOrderDigital.Ordv_ReservationSendPhotoName AS 员工编号,
  53. dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_ReservationSendPhotoTime)) AS 工作时间,
  54. dbo.tb_ErpOrderDigital.Ordv_ReservationSendPhotoTime AS 工作时间查询
  55. FROM dbo.tb_ErpUser LEFT OUTER JOIN
  56. dbo.tb_ErpOrderDigital ON
  57. dbo.tb_ErpOrderDigital.Ordv_ReservationSendPhotoName = dbo.tb_ErpUser.User_EmployeeID LEFT OUTER JOIN
  58. dbo.tb_ErpOrder ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
  59. left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
  60. WHERE (dbo.tb_ErpOrderDigital.Ordv_ReservationSendPhotoStatus IN (''0'', ''1''))
  61. '
  62. GO
  63. IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_MyWorkSendPhoto_Ok')
  64. BEGIN
  65. DROP VIEW [dbo].BView_MyWorkSendPhoto_Ok
  66. END
  67. GO
  68. SET ANSI_NULLS ON
  69. GO
  70. SET QUOTED_IDENTIFIER ON
  71. GO
  72. IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_MyWorkSendPhoto_Ok]'))
  73. EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[BView_MyWorkSendPhoto_Ok]
  74. AS
  75. SELECT
  76. tb_ErpOrder.ID, CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
  77. dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
  78. Cus_Name AS 客户姓名,
  79. dbo.tb_ErpUser.User_DividedShop AS 分店编号, dbo.tb_ErpUser.User_Name AS 员工姓名,
  80. dbo.tb_ErpOrderDigital.Ordv_SendPhotoName AS 员工编号,
  81. dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_SendPhotoTime)) AS 工作时间,
  82. dbo.tb_ErpOrderDigital.Ordv_SendPhotoTime AS 工作时间查询
  83. FROM dbo.tb_ErpUser LEFT OUTER JOIN
  84. dbo.tb_ErpOrderDigital ON
  85. dbo.tb_ErpOrderDigital.Ordv_SendPhotoName = dbo.tb_ErpUser.User_EmployeeID LEFT OUTER JOIN
  86. dbo.tb_ErpOrder ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
  87. left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
  88. WHERE (dbo.tb_ErpOrderDigital.Ordv_ReservationSendPhotoStatus = ''2'')
  89. '
  90. GO
  91. -------------------2015-08-21------------------------
  92. --打印设置(字体大小)
  93. if not exists
  94. (select * from syscolumns where id=object_id('tb_ErpPrinterSet') and name='ps_FontSize')
  95. begin
  96. alter table tb_ErpPrinterSet add ps_FontSize nvarchar(50) NULL
  97. end
  98. IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'tb_ErpPrinterSet', N'COLUMN',N'ps_FontSize'))
  99. EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'字体大小' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpPrinterSet', @level2type=N'COLUMN',@level2name=N'ps_FontSize'
  100. GO
  101. --影楼微分享帐号
  102. if not exists
  103. (select * from syscolumns where id=object_id('tb_ErpCompanyInfo') and name='Company_MicroShareAccount')
  104. begin
  105. alter table tb_ErpCompanyInfo add Company_MicroShareAccount nvarchar(200) NULL
  106. end
  107. IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'tb_ErpCompanyInfo', N'COLUMN',N'Company_MicroShareAccount'))
  108. EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'微分享帐号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpCompanyInfo', @level2type=N'COLUMN',@level2name=N'Company_MicroShareAccount'
  109. GO
  110. --影楼微分享密码
  111. if not exists
  112. (select * from syscolumns where id=object_id('tb_ErpCompanyInfo') and name='Company_MicroSharePassword')
  113. begin
  114. alter table tb_ErpCompanyInfo add Company_MicroSharePassword nvarchar(200) NULL
  115. end
  116. IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'tb_ErpCompanyInfo', N'COLUMN',N'Company_MicroSharePassword'))
  117. EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'微分享密码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpCompanyInfo', @level2type=N'COLUMN',@level2name=N'Company_MicroSharePassword'
  118. GO